package cn.pkubangbang.demo.democontact.entity;

import java.io.Serializable;
import java.time.Instant;
import java.util.Objects;

/**
 * @Author: zhangzhenbang@k2data.com.cn
 * @Date: 2018-08-23 14:05
 */
public class Person implements Serializable {

    private Integer id;
    private String name;
    private Instant registerTime;
    private Instant lastActive;

    public Person() {
    }

    public Person(Integer id, String name, Instant registerTime, Instant lastActive) {
        this.id = id;
        this.name = name;
        this.registerTime = registerTime;
        this.lastActive = lastActive;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Instant getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(Instant registerTime) {
        this.registerTime = registerTime;
    }

    public Instant getLastActive() {
        return lastActive;
    }

    public void setLastActive(Instant lastActive) {
        this.lastActive = lastActive;
    }

    /**
     * 将相等条件放宽为id相等
     * @param o 另一个对象
     * @return true 如果另一个对象也是Person并且id相同； false otherwise.
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Person person = (Person) o;
        return Objects.equals(getId(), person.getId());
    }

    @Override
    public int hashCode() {

        return Objects.hash(getId());
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Person{");
        sb.append("id=").append(id);
        sb.append(", name='").append(name).append('\'');
        sb.append(", registerTime=").append(registerTime);
        sb.append(", lastActive=").append(lastActive);
        sb.append('}');
        return sb.toString();
    }
}
